package com.yuyou.fn.common.util;

import com.github.wens.mybatisplus.plugins.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/16.
 */
public class PageUtils {
    public  static <T> Page<T> findPageByList(List<T> list,int pageNo,int pageSize){
        Page<T> page=new Page<>(pageNo,pageSize);
        if (pageNo<1 ||pageSize<0 || list==null || list.size()<=0){
            page.setTotal(0);
            return page;
        }
        List<T> tempList=new ArrayList<>();
        for (int i=(pageNo-1)*pageSize;i<pageSize && i<list.size();i++){
            tempList.add(list.get(i));
        }
        page.setTotal(list.size());
        page.setRecords(tempList);
        return page;
    }
}
